import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs/Observable";
import {AppUrl} from "../../app/app.general";

@Injectable()
export class LoginService {
  constructor(private http: HttpClient) {
  }

  login(user: any): Observable<any> {
    return this.http.post(AppUrl.auth.login, user);
  }

  // logout(){
  //   this.http.post(AppUrl.auth.logout,{}).toPromise();
  // }

  refreshToken(): Observable<any> {
    return this.http.get(AppUrl.auth.refresh);
  }

  signUp(user: any, editMode: boolean): Observable<any> {
    if (!editMode)
      return this.http.post(AppUrl.general.signUp, user);
    return this.http.post(AppUrl.user.edit, user);
  }

  delete(userid): Observable<any>{
    return this.http.post(AppUrl.user.delete,{userid:userid});
  }

}
